package yun1.shuxue;

import java.util.Scanner;

public class AB100 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();	
		
		System.out.println(gcd(a,b));	
	}
	
	public static int gcd(int a,int b) {
		return b==0?a:gcd(b,a%b);
	}
	
	public static int gcd2(int a,int b) {
		while(b>0) {
			int temp = a%b;
			a = b;
			b = temp;
		}
		return a;
	}
	

}
